//
//  StatusCellBottomView.swift
//  SinaWeibo
//
//  Created by 张子国 on 15/11/17.
//  Copyright © 2015年 张子国. All rights reserved.
//

import UIKit
import SnapKit

class StatusCellBottomView: UIView {
    @objc private func relayBtnDidClick() {
        let temp = TempViewController()
        relaybtn.NavControl()?.pushViewController(temp, animated: true)
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = UIColor(white: 0.98, alpha: 1)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //MARK: 设置UI
    private func setupUI() {
        addSubview(relaybtn)
        addSubview(commenbtn)
        addSubview(likebtn)
        
        
        let w: CGFloat = 0.5
        let scale = 0.4
        //设置布局
        relaybtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(snp_top)
            make.left.equalTo(snp_left)
            make.bottom.equalTo(snp_bottom)
        }
        //分割线用UIView 来代替
        let sepView1 = sepView()
        addSubview(sepView1)
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(relaybtn.snp_right)
            make.height.equalTo(relaybtn.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(w)
        }

        commenbtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(relaybtn.snp_top)
            make.left.equalTo(relaybtn.snp_right)
            make.width.equalTo(relaybtn.snp_width)
            make.bottom.equalTo(relaybtn.snp_bottom)
        }
        
        let sepView2 = sepView()
        addSubview(sepView2)
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commenbtn.snp_right)
            make.height.equalTo(commenbtn.snp_height).multipliedBy(scale)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(w)
        }
       
        likebtn.snp_makeConstraints { (make) -> Void in
            make.top.equalTo(commenbtn.snp_top)
            make.left.equalTo(commenbtn.snp_right)
            make.right.equalTo(self.snp_right)
            make.width.equalTo(commenbtn.snp_width)
            make.bottom.equalTo(commenbtn.snp_bottom)
        }
        //监听事件
        relaybtn .addTarget(self, action: "relayBtnDidClick", forControlEvents: .TouchUpInside)
    }
    
    
    
    
    //MARK: 懒加载控件
    private func sepView() ->UIView {
    let v = UIView()
    v.backgroundColor = .darkGrayColor()
    return v
    }
    
    
    private lazy var relaybtn : UIButton = UIButton(title: "转发", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_retweet", size: 10)
    private lazy var commenbtn : UIButton = UIButton(title: "评论", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_comment", size: 10)
    private lazy var likebtn : UIButton = UIButton(title: "赞", backImage: nil, color: UIColor.darkGrayColor(), image: "timeline_icon_unlike", size: 10)

}
